﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DIS.Infrastructure.Entities.Repository;
using DIS.Infrastructure.Entities.Enum;
using DIS.Infrastructure.Entities.Cache;

namespace DIS.Infrastructure.Entities.Entity
{
    public class LongHaul : IAccessible<T_LongHaul, LongHaul>, ILogicEntity<T_LongHaul, LongHaul>
    {
        public int Id { get; set; }

        public int ProjectId { get; set; }

        public string Year { get; set; }

        public string Month { get; set; }

        public string UserName { get; set; }

        public string StartDate { get; set; }

        public string EndDate { get; set; }

        public int TotalDays { get; set; }

        public decimal TotalFee { get; set; }

        public int InvoiceCount { get; set; }

        public decimal AllowanceMoney { get; set; }

        public int Status { get; set; }

        public User user { get; set; }

        public LongHaul LoadUser(T_User user)
        {
            this.user = new User().Set(user);
            return this;
        }

        public Project project { get; set; }

        public LongHaul LoadProject(T_Project project)
        {
            this.project = new Project().Set(project);
            return this;
        }

        protected override void Covariant(T_LongHaul model)
        {
            this.Id = model.Id;
            this.ProjectId = model.ProjectId;
            this.Year = model.Year;
            this.Month = model.Month;
            this.UserName = model.UserName;
            this.StartDate = model.StartDate;
            this.EndDate = model.EndDate;
            this.TotalDays = model.TotalDays;
            this.TotalFee = model.TotalFee;
            this.InvoiceCount = model.InvoiceCount;
            this.Status = model.Status;
            this.AllowanceMoney = model.AllowanceMoney;
        }
        protected override T_LongHaul Inverter(LongHaul model)
        {
            return new T_LongHaul()
            {
                Id = model.Id,
                ProjectId=model.ProjectId,
                Year = model.Year,
                Month = model.Month,
                UserName = model.UserName,
                StartDate = model.StartDate,
                EndDate = model.EndDate,
                TotalDays = model.TotalDays,
                TotalFee = model.TotalFee,
                InvoiceCount = model.InvoiceCount,
                Status = model.Status,
                AllowanceMoney=model.AllowanceMoney
            };
        }
        public LongHaul Set(T_LongHaul dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
